package com.ezandroid.library.image.ext.core.display;

import android.graphics.Bitmap;

import com.ezandroid.library.image.ext.core.display.blur.BlurProcess;
import com.ezandroid.library.image.ext.core.display.blur.NativeBlurProcess;
import com.nostra13.universalimageloader.core.assist.LoadedFrom;
import com.nostra13.universalimageloader.core.display.BitmapDisplayer;
import com.nostra13.universalimageloader.core.imageaware.ImageAware;

public class BlurBitmapDisplayer implements BitmapDisplayer {

    private final int depth;

    public BlurBitmapDisplayer(int depth) {
        this.depth = depth;
    }

    @Override
    public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) {
        BlurProcess blurProcess = new NativeBlurProcess();
        Bitmap blurBitmap = blurProcess.blur(bitmap, depth);
        if (blurBitmap != null && !blurBitmap.isRecycled()) {
            imageAware.setImageBitmap(blurBitmap);
        }
    }
}
